const devUrl_3031 = "http://localhost:3031"
const baseUrl_3030 = "https://www.qlsyyun.com:3030"

const devUrl_3001 = "http://localhost:3001"
const baseUrl_3000 = "https://www.qlsyyun.com:3000"

module.exports = {
// 3030端口
 request_3031 : ({ url, method, data }) => {
  return new Promise((resolve, reject) => {
    wx.request({
      url: baseUrl_3030 + url,
      method,
      data: data,
      header: {
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      success: (res) => { 
        if (res.statusCode === 200) {
          resolve(res.data)
        } else {
          reject(res.data.error)
        }
      },
      fail: (err) => {
        reject(err)
      }
    })
  })
},
// 3000端口
 request_3001 : ({ url, method, data })=>{
   wx.showLoading({
     title: '加载中...',
   })
  return new Promise((resolve, reject) => {
    wx.request({
      url: baseUrl_3000 + url,
      method,
      data: data,
      header: {
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      success: (res) => {
        if (res.statusCode === 200) {
          wx.hideLoading()
          resolve(res.data)
        } else {
          wx.hideLoading()
          reject(res.data.error)
        }
      },
      fail: (err) => {
        wx.hideLoading()
        reject(err)
      }
    })
  })
}
}